03. Fast Google Search Responses

Fast Google Search Responses

INSTRUCTOR NOTE:

Ilya: I know what you're thinking… "Wait a second, but the header is not the same for each user, because once you sign-in, you have the customized icon and navigation in top right corner!" … right?

Well, this optimization still works! The Google search team has built an optimized service that is able to retrieve and build the customized header that includes the custom user information in mere milliseconds after the request first arrives at the server - as a result, they can flush the header back to the client even before they have parsed the search query. Alternatively, many sites use a static header and then use JavaScript to fill in the custom bits - this allows them to serve the same header regardless of user status.

In either case, the important part is that the server does not have wait to render the full response before returning it to the client. The sooner you can flush some data, the sooner the browser can start building the DOM, and discover and dispatch requests for other critical resources.

See Flushing the Document Early to learn more.

Also, check out Chunk Scatter, a fantastic tool for visualizing chunked HTTP responses.

Follow your instructors!

+Ilya Grigorik, @igrigorik

@cwpittman